package com.itheima.test1;

public class Eater extends Thread {
    private Desk desk;

    public Eater() {
    }

    public Eater(Desk desk) {
        this.desk = desk;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (desk.getOb()) {
                if (desk.isB()) {
                    System.out.println("吃货吃汉堡");
                    desk.setB(false);
                    desk.getOb().notifyAll();
                } else {
                    try {
                        desk.getOb().wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
